#![allow(unused_imports,dead_code,unused_assignments)]
use axum::{
    extract::{Form, Query, Json, Multipart,DefaultBodyLimit},
    routing::{get,post},
    response::Response,
    body::{Body, Bytes},
    Router
};
use crate::domain::OrderItemBean;
use crate::domain::OrderItemQueryRequest;
use crate::serviceimpl::cust_order_service::find_cust_order_by_id as service_find_cust_order_by_id;
use crate::serviceimpl::goods_service::find_goods_by_id as service_find_goods_by_id;
use crate::serviceimpl::order_item_service::activate_all_order_items as service_activate_all_order_items;
use crate::serviceimpl::order_item_service::activate_order_item as service_activate_order_item;
use crate::serviceimpl::order_item_service::add_order_item as service_add_order_item;
use crate::serviceimpl::order_item_service::clone_all_order_items as service_clone_all_order_items;
use crate::serviceimpl::order_item_service::clone_order_item as service_clone_order_item;
use crate::serviceimpl::order_item_service::count_search_order_items_by_fields_records as service_count_search_order_items_by_fields_records;
use crate::serviceimpl::order_item_service::delete_all_order_items as service_delete_all_order_items;
use crate::serviceimpl::order_item_service::delete_order_item as service_delete_order_item;
use crate::serviceimpl::order_item_service::find_order_item_by_id as service_find_order_item_by_id;
use crate::serviceimpl::order_item_service::find_order_item_by_name as service_find_order_item_by_name;
use crate::serviceimpl::order_item_service::list_active_order_items as service_list_active_order_items;
use crate::serviceimpl::order_item_service::list_all_order_items as service_list_all_order_items;
use crate::serviceimpl::order_item_service::search_order_items_by_fields as service_search_order_items_by_fields;
use crate::serviceimpl::order_item_service::search_order_items_by_fields_by_page as service_search_order_items_by_fields_by_page;
use crate::serviceimpl::order_item_service::soft_delete_all_order_items as service_soft_delete_all_order_items;
use crate::serviceimpl::order_item_service::soft_delete_order_item as service_soft_delete_order_item;
use crate::serviceimpl::order_item_service::toggle_one_order_item as service_toggle_one_order_item;
use crate::serviceimpl::order_item_service::toggle_order_item as service_toggle_order_item;
use crate::serviceimpl::order_item_service::update_order_item as service_update_order_item;
use crate::utils::excel_util::export_excel_workbook_with_image;
use crate::utils::pdf_util::export_pdf_with_images;
use serde::{Deserialize};
use serde_json::{Value,Map};
use std::fs;
use tower_http::{trace::TraceLayer};


#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OrderItemRequest {
	pub id: Option<i64>,
	pub name: Option<String>,
	pub active: Option<bool>,
	pub price: Option<f64>,
	pub amount: Option<i32>,
	pub goods_id: Option<i64>,
	pub cust_order_id: Option<i64>,
}

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct IdsRequest {
	pub ids: String,
}

pub fn order_item_controller() -> Router {
	Router::new()
	.route("/listAllOrderItems", post(list_all_order_items))
	.route("/updateOrderItem", post(update_order_item))
	.route("/deleteOrderItem", post(delete_order_item))
	.route("/addOrderItem", post(add_order_item))
	.route("/softDeleteOrderItem", post(soft_delete_order_item))
	.route("/findOrderItemById", post(find_order_item_by_id))
	.route("/findOrderItemByName", post(find_order_item_by_name))
	.route("/listActiveOrderItems", post(list_active_order_items))
	.route("/deleteAllOrderItems", post(delete_all_order_items))
	.route("/softDeleteAllOrderItems", post(soft_delete_all_order_items))
	.route("/toggleOrderItem", post(toggle_order_item))
	.route("/toggleOneOrderItem", post(toggle_one_order_item))
	.route("/searchOrderItemsByFieldsByPage", post(search_order_items_by_fields_by_page))
	.route("/activateOrderItem", post(activate_order_item))
	.route("/activateAllOrderItems", post(activate_all_order_items))
	.route("/exportOrderItems", get(export_order_items))
	.route("/exportOrderItemsPDF", get(export_order_items_pdf))
	.route("/filterOrderItemsExcel", get(filter_order_items_excel))
	.route("/filterOrderItemsPDF", get(filter_order_items_pdf))
	.route("/cloneOrderItem", post(clone_order_item))
	.route("/cloneAllOrderItems", post(clone_all_order_items))
	.route("/checkAccessOrderItem", get(check_access_order_item))
	.layer(DefaultBodyLimit::max(2*1024*1024))
	.layer(TraceLayer::new_for_http())
}
pub async fn activate_all_order_items(Form(ids_request):Form<IdsRequest>) ->String {
	let ids = ids_request.ids;
	let string_ids:Vec<&str> = ids.split(',').collect();
	let mut ids:Vec<i64> = Vec::new();

	let vecter_iterator = string_ids.iter();
	for id in vecter_iterator {
		ids.push(id.parse::<i64>().unwrap());
	}

	let _result = service_activate_all_order_items(ids).await;
	match _result {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(_result) => {
			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				Value::from(""),
			);
			
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn activate_order_item(Form(order_item_request):Form<OrderItemRequest>) ->String {
	let id = order_item_request.id.unwrap_or_default();
	let _result = service_activate_order_item(id).await;
	match _result {
		Err(_) => {
			println!("Error!");
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(_result) => {
			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				Value::from(""),
			);
			
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			//println!("{}", resultjson);
			return resultjson;
		}
	}
}

pub async fn add_order_item(Json(order_item_request):Json<OrderItemRequest>) ->String {
	let id = order_item_request.id.unwrap_or_default();
	let name = order_item_request.name.unwrap_or_default();
	let active = order_item_request.active.unwrap_or_default();
	let price = order_item_request.price.unwrap_or_default();
	let amount = order_item_request.amount.unwrap_or_default();
	let goods_id = order_item_request.goods_id.unwrap_or_default();
	let cust_order_id = order_item_request.cust_order_id.unwrap_or_default();

	let order_item = OrderItemBean{
	id : id,
	name : name,
	active : active,
	price : price,
	amount : amount,
	goods_id : goods_id,
	cust_order_id : cust_order_id,
	};
	
	let _result = service_add_order_item(order_item).await;
	match _result {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(_result) => {
			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				Value::from(""),
			);
			
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn check_access_order_item() ->String {
	r#"{  "rows": null,  "success": true}"#.to_string()
}

pub async fn clone_all_order_items(Form(ids_request):Form<IdsRequest>) ->String {
	let ids = ids_request.ids;
	let string_ids:Vec<&str> = ids.split(',').collect();
	let mut ids:Vec<i64> = Vec::new();

	let vecter_iterator = string_ids.iter();
	for id in vecter_iterator {
		ids.push(id.parse::<i64>().unwrap());
	}

	let _result = service_clone_all_order_items(ids).await;
	match _result {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(_result) => {
			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				Value::from(""),
			);
			
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn clone_order_item(Form(order_item_request):Form<OrderItemRequest>) ->String {
	let id = order_item_request.id.unwrap_or_default();
	let _result = service_clone_order_item(id).await;
	match _result {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(_result) => {
			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				Value::from(""),
			);
			
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn delete_all_order_items(Form(ids_request):Form<IdsRequest>) ->String {
	let ids = ids_request.ids;
	let string_ids:Vec<&str> = ids.split(',').collect();
	let mut ids:Vec<i64> = Vec::new();

	let vecter_iterator = string_ids.iter();
	for id in vecter_iterator {
		ids.push(id.parse::<i64>().unwrap());
	}

	let _result = service_delete_all_order_items(ids).await;
	match _result {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(_result) => {
			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				Value::from(""),
			);
			
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn delete_order_item(Form(order_item_request):Form<OrderItemRequest>) ->String {
	let id = order_item_request.id.unwrap_or_default();
	let _result = service_delete_order_item(id).await;
	match _result {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(_result) => {
			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				Value::from(""),
			);
			
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn export_order_items() ->Response<Body> {
	let list = service_list_all_order_items().await.unwrap();
	let mut contents : Vec<Vec<String>> = Vec::new();
	let sheet_name = "订单项信息表".to_string();
	let headers = vec!["序号".to_string(),"名字".to_string(),"活跃".to_string(),"价格".to_string(),"商品数".to_string(),"货品".to_string(),"订单".to_string()];
	let is_images = vec![false,false,false,false,false,false,false];
	for order_item in list {
		let goods_id = order_item.goods_id;
		let mut goods_id_name0 = "".to_string();
		if goods_id > 0 {
			let goods_id_type0 = service_find_goods_by_id(goods_id).await.unwrap();
			if goods_id_type0.id != 0 {
				goods_id_name0 = goods_id_type0.name;
			}
		}
		let cust_order_id = order_item.cust_order_id;
		let mut cust_order_id_name0 = "".to_string();
		if cust_order_id > 0 {
			let cust_order_id_type0 = service_find_cust_order_by_id(cust_order_id).await.unwrap();
			if cust_order_id_type0.id != 0 {
				cust_order_id_name0 = cust_order_id_type0.name;
			}
		}

		let row = vec![order_item.id.to_string(),order_item.name,order_item.active.to_string(),order_item.price.to_string(),order_item.amount.to_string(),goods_id_name0,cust_order_id_name0];
		contents.push(row);
	}

	let full_file_path = "./template/temp/orderItems.xlsx";
	export_excel_workbook_with_image(full_file_path.to_string(),sheet_name, headers, contents, is_images);
	
	
	let data = fs::read(full_file_path).unwrap();
	let _ = fs::remove_file(full_file_path);

	Response::builder()
	.header("Content-Type", "application/octet-stream")
	.header("Content-Disposition", "attachment; filename=orderItems.xlsx")
	.header("Content-Transfer-Encoding", "binary")
	.body(Body::from(data))
	.unwrap()
}

pub async fn export_order_items_pdf() ->Response<Body> {
	let list = service_list_all_order_items().await.unwrap();
	let mut contents : Vec<Vec<String>> = Vec::new();
	let sheet_name = "订单项信息表".to_string();
	let headers = vec!["序号".to_string(),"名字".to_string(),"活跃".to_string(),"价格".to_string(),"商品数".to_string(),"货品".to_string(),"订单".to_string()];
	let is_images = vec![false,false,false,false,false,false,false];
	for order_item in list {
		let goods_id = order_item.goods_id;
		let mut goods_id_name0 = "".to_string();
		if goods_id > 0 {
			let goods_id_type0 = service_find_goods_by_id(goods_id).await.unwrap();
			if goods_id_type0.id != 0 {
				goods_id_name0 = goods_id_type0.name;
			}
		}
		let cust_order_id = order_item.cust_order_id;
		let mut cust_order_id_name0 = "".to_string();
		if cust_order_id > 0 {
			let cust_order_id_type0 = service_find_cust_order_by_id(cust_order_id).await.unwrap();
			if cust_order_id_type0.id != 0 {
				cust_order_id_name0 = cust_order_id_type0.name;
			}
		}

		let row = vec![order_item.id.to_string(),order_item.name,order_item.active.to_string(),order_item.price.to_string(),order_item.amount.to_string(),goods_id_name0,cust_order_id_name0];
		contents.push(row);
	}

	let data = export_pdf_with_images(sheet_name, headers, contents, is_images);
	
	Response::builder()
	.header("Content-Type", "application/octet-stream")
	.header("Content-Disposition", "attachment; filename=orderItems.pdf")
	.header("Content-Transfer-Encoding", "binary")
	.body(Body::from(data))
	.unwrap()
}

pub async fn filter_order_items_excel(Query(order_item_query_request):Query<OrderItemQueryRequest>) ->Response<Body> {
	let list = service_search_order_items_by_fields(order_item_query_request).await.unwrap();
	let mut contents : Vec<Vec<String>> = Vec::new();
	let sheet_name = "订单项信息表".to_string();
	let headers = vec!["序号".to_string(),"名字".to_string(),"活跃".to_string(),"价格".to_string(),"商品数".to_string(),"货品".to_string(),"订单".to_string()];
	let is_images = vec![false,false,false,false,false,false,false];
	for order_item in list {
		let goods_id = order_item.goods_id;
		let mut goods_id_name0 = "".to_string();
		if goods_id > 0 {
			let goods_id_type0 = service_find_goods_by_id(goods_id).await.unwrap();
			if goods_id_type0.id != 0 {
				goods_id_name0 = goods_id_type0.name;
			}
		}
		let cust_order_id = order_item.cust_order_id;
		let mut cust_order_id_name0 = "".to_string();
		if cust_order_id > 0 {
			let cust_order_id_type0 = service_find_cust_order_by_id(cust_order_id).await.unwrap();
			if cust_order_id_type0.id != 0 {
				cust_order_id_name0 = cust_order_id_type0.name;
			}
		}

		let row = vec![order_item.id.to_string(),order_item.name,order_item.active.to_string(),order_item.price.to_string(),order_item.amount.to_string(),goods_id_name0,cust_order_id_name0];
		contents.push(row);
	}

	let full_file_path = "./template/temp/orderItems.xlsx";
	export_excel_workbook_with_image(full_file_path.to_string(),sheet_name, headers, contents, is_images);
	
	
	let data = fs::read(full_file_path).unwrap();
	let _ = fs::remove_file(full_file_path);

	Response::builder()
	.header("Content-Type", "application/octet-stream")
	.header("Content-Disposition", "attachment; filename=orderItems.xlsx")
	.header("Content-Transfer-Encoding", "binary")
	.body(Body::from(data))
	.unwrap()
}

pub async fn filter_order_items_pdf(Query(order_item_query_request):Query<OrderItemQueryRequest>) ->Response<Body> {
	let list = service_search_order_items_by_fields(order_item_query_request).await.unwrap();
	let mut contents : Vec<Vec<String>> = Vec::new();
	let sheet_name = "订单项信息表".to_string();
	let headers = vec!["序号".to_string(),"名字".to_string(),"活跃".to_string(),"价格".to_string(),"商品数".to_string(),"货品".to_string(),"订单".to_string()];
	let is_images = vec![false,false,false,false,false,false,false];
	for order_item in list {
		let goods_id = order_item.goods_id;
		let mut goods_id_name0 = "".to_string();
		if goods_id > 0 {
			let goods_id_type0 = service_find_goods_by_id(goods_id).await.unwrap();
			if goods_id_type0.id != 0 {
				goods_id_name0 = goods_id_type0.name;
			}
		}
		let cust_order_id = order_item.cust_order_id;
		let mut cust_order_id_name0 = "".to_string();
		if cust_order_id > 0 {
			let cust_order_id_type0 = service_find_cust_order_by_id(cust_order_id).await.unwrap();
			if cust_order_id_type0.id != 0 {
				cust_order_id_name0 = cust_order_id_type0.name;
			}
		}

		let row = vec![order_item.id.to_string(),order_item.name,order_item.active.to_string(),order_item.price.to_string(),order_item.amount.to_string(),goods_id_name0,cust_order_id_name0];
		contents.push(row);
	}

	let data = export_pdf_with_images(sheet_name, headers, contents, is_images);

	Response::builder()
	.header("Content-Type", "application/octet-stream")
	.header("Content-Disposition", "attachment; filename=orderItems.pdf")
	.header("Content-Transfer-Encoding", "binary")
	.body(Body::from(data))
	.unwrap()
}

pub async fn find_order_item_by_id(Form(order_item_request):Form<OrderItemRequest>) ->String {
	let id = order_item_request.id.unwrap_or_default();
	let order_item = service_find_order_item_by_id(id).await;
	match order_item {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(order_item) => {
			let json = serde_json::to_string_pretty(&order_item).unwrap();

			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				serde_json::from_str(&json).unwrap(),
			);
		
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn find_order_item_by_name(Form(order_item_request):Form<OrderItemRequest>) ->String {
	let name = order_item_request.name.unwrap_or_default();
	let order_item = service_find_order_item_by_name(name).await;
	match order_item {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(order_item) => {
			let json = serde_json::to_string_pretty(&order_item).unwrap();

			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				serde_json::from_str(&json).unwrap(),
			);
		
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn list_active_order_items() ->String {
	let order_items = service_list_active_order_items().await;
	match order_items {
		Err(_) => {
			println!("Error!");
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(order_items) => {
			let json = serde_json::to_string_pretty(&order_items).unwrap();
			//println!("{}", json);

			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				serde_json::from_str(&json).unwrap(),
			);
		
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			//println!("{}", resultjson);
			return resultjson;
		}
	}
}

pub async fn list_all_order_items() ->String {
	let order_items = service_list_all_order_items().await;
	match order_items {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(order_items) => {
			let json = serde_json::to_string_pretty(&order_items).unwrap();

			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				serde_json::from_str(&json).unwrap(),
			);
		
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn search_order_items_by_fields_by_page(Form(order_item_query_request):Form<OrderItemQueryRequest>) ->String {
	let order_items = service_search_order_items_by_fields_by_page(order_item_query_request.clone()).await;
	let total = service_count_search_order_items_by_fields_records(order_item_query_request.clone()).await.unwrap().count_num;
	match order_items {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(order_items) => {
			let json = serde_json::to_string_pretty(&order_items).unwrap();

			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert("total".to_string(), Value::from(total));
			map.insert(
				"rows".to_string(),
				serde_json::from_str(&json).unwrap(),
			);
		
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn soft_delete_all_order_items(Form(ids_request):Form<IdsRequest>) ->String {
	let ids = ids_request.ids;
	let string_ids:Vec<&str> = ids.split(',').collect();
	let mut ids:Vec<i64> = Vec::new();

	let vecter_iterator = string_ids.iter();
	for id in vecter_iterator {
		ids.push(id.parse::<i64>().unwrap());
	}

	let _result = service_soft_delete_all_order_items(ids).await;
	match _result {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(_result) => {
			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				Value::from(""),
			);
			
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn soft_delete_order_item(Form(order_item_request):Form<OrderItemRequest>) ->String {
	let id = order_item_request.id.unwrap_or_default();
	let _result = service_soft_delete_order_item(id).await;
	match _result {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(_result) => {
			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				Value::from(""),
			);
			
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn toggle_one_order_item(Form(order_item_request):Form<OrderItemRequest>) ->String {
	let id = order_item_request.id.unwrap_or_default();
	let _result = service_toggle_one_order_item(id).await;
	match _result {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(_result) => {
			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				Value::from(""),
			);
			
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn toggle_order_item(Form(order_item_request):Form<OrderItemRequest>) ->String {
	let id = order_item_request.id.unwrap_or_default();
	let _result = service_toggle_order_item(id).await;
	match _result {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(_result) => {
			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				Value::from(""),
			);
			
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

pub async fn update_order_item(Json(order_item_request):Json<OrderItemRequest>) ->String {
	let id = order_item_request.id.unwrap_or_default();
	let name = order_item_request.name.unwrap_or_default();
	let active = order_item_request.active.unwrap_or_default();
	let price = order_item_request.price.unwrap_or_default();
	let amount = order_item_request.amount.unwrap_or_default();
	let goods_id = order_item_request.goods_id.unwrap_or_default();
	let cust_order_id = order_item_request.cust_order_id.unwrap_or_default();
	let _current_order_item = service_find_order_item_by_id(id).await.unwrap();

	let order_item = OrderItemBean{
	id : id,
	name : name,
	active : active,
	price : price,
	amount : amount,
	goods_id : goods_id,
	cust_order_id : cust_order_id,
	};
	
	let _result = service_update_order_item(order_item).await;
	match _result {
		Err(_) => {
			r#"{  "rows": null,  "success": true}"#.to_string()
		},
		Ok(_result) => {
			let mut map = Map::new();
			map.insert("success".to_string(), Value::from(true));
			map.insert(
				"rows".to_string(),
				Value::from(""),
			);
			
			let resultjson = serde_json::to_string_pretty(&map).unwrap();
			return resultjson;
		}
	}
}

